{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "37fcad96",
   "metadata": {},
   "outputs": [],
   "source": [
    "import cv2 as cv\n",
    "\n",
    "gray_img = cv.imread(\"../data/sudoku.png\",0)\n",
    "\n",
    "#sobel边缘检测\n",
    "#通过滤波核与图像卷积，得到卷积和作为边缘图当前位置的值\n",
    "x = cv.Sobel(gray_img,cv.CV_16S,1,0)\n",
    "y = cv.Sobel(gray_img,cv.CV_16S,0,1)\n",
    "#cv.convertScaleAbs(scrl,dstl,alpha1,beta1)\n",
    "#可选参数alpha是伸缩参数，beta是加到结果上的一个值，结果返回uint类型的图像\n",
    "Scale_absX = cv.convertScaleAbs(x)     #convert 转换  scale缩放\n",
    "Scale_absY = cv.convertScaleAbs(y)\n",
    "result = cv.addWeighted(Scale_absX,0.5,Scale_absY,0.5,0)\n",
    "\n",
    "#显示结果\n",
    "cv.imshow('img',gray_img)\n",
    "cv.imshow('Scale_absX',Scale_absX)\n",
    "cv.imshow('Scale_absY',Scale_absY)\n",
    "cv.imshow('result',result)\n",
    "cv.waitKey(0)\n",
    "cv.destoryAllWindows()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "43d3eaf5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
